package cn.j2e.login.service;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.cpms.dto.LoginUser;

import cn.j2e.login.service.iter.ILoginService;
import cn.j2web.core.dao.iter.IDao;
import cn.j2web.core.exceptions.LoginException;

@Service("loginService")
public class LoginServiceImpl implements ILoginService {
	
	@Resource(name="dao")
	private IDao dao;
	
	@Value("#{dkog['dkog.page.login']}")
	private String loginPage;
	
	@Value("#{dkog['dkog.page.main']}")
	private String mainPage;
	
	@Value("#{dkog['dkog.page.login.validKey']}")
	private String validKey;
	
	@Value("#{dkog['dkog.page.login.isSavePasswordToCookie']}")
	private String isSavePasswordToCookie;
	
	
	
	public LoginUser getLoginUser(LoginUser userDto) throws LoginException {
		LoginUser loginUser = new LoginUser();
		loginUser.setUserName("admin");
		loginUser.setStatus(LoginUser.loginStatuEnum.LOGIN_SUCCESS);
		return loginUser;
	}

	public LoginUser getLoginUser(String loginName) throws LoginException {
		LoginUser loginUser = new LoginUser();
		loginUser.setUserName("admin");
		// 设置登录成功状态：1，表示成功！
		loginUser.setStatus(LoginUser.loginStatuEnum.LOGIN_SUCCESS);
		return loginUser;
	}


	public String getMainJspView() throws LoginException {
		return this.mainPage;
	}

	public String getLoginJspView() throws LoginException {
		return this.loginPage;
	}

	public String getValidKey() throws LoginException {
		return this.validKey;
	}
	
	public boolean getIsSavePasswordToCookie() throws LoginException {
		return Boolean.parseBoolean(isSavePasswordToCookie);
	}

}
